;
define(["MComponent","MWIETransition","MPanel"], function(MComponent,MWIETransition,MPanel) {
	/**
	 * 标题面板
	 * @param {Object} background 背景
	 */
	var MPTitled = function(background) {
		this.dom = this.query("<div></div>","MPTitled");
		this.setBackground(background);
		
		//标题面板
		var title = new MPanel();
		
		//正文面板
		var content = new MWIETransition();
		
		//组件
		var components  = [];
		
		/**
		 * 设置标题面板
		 */
		this.setTitle = function(value){
			if(value instanceof MComponent){
				title.setHeight(value.getHeight());
			}
			title.setContent(value);
			
			return this;
		};
		
		/**
		 * 获得标题面板
		 */
		this.getTitle = function(){
			return title;
		}
		
		/**
		 * 放入面板
		 */
		this.putPanel = function(value){
			if(value instanceof MComponent){
				content.append(value);
			}else{
				var panel = new MPanel();
				panel.setFullToParent();
				panel.setHeight(16);
				panel.setContent(value);
				content.append(panel);
			}
			components[components.length] = panel;
			return this;
		}
		
		/**
		 * 更新面板
		 */
		this.updatePanels = function(func){
			if(func && typeof func === 'function'){
				for(var component in components){
					func(components[component]);
				}
			}
			
		}
		
		this.getPanel = function(index){
			return components[index];
		}
		
		this.getContent = function(){
			return content;
		}
		
		this.init();
		this.init = function(){
			title.setHeight(16);
			title.setStyle("width","100%");
			this.append(title);
			this.append(content);
			
		}
		this.init();
	};
	mofum.extend(MPTitled, MComponent);
	return MPTitled;
});